#include "BieuThucTich.h"


BieuThucTich::BieuThucTich(void)
{
}

BieuThucTich::BieuThucTich(BieuThuc* btu,BieuThuc* btv)
{
	this->m_pBieuThuc = btu;
	this->m_pNext = btv;
}

BieuThuc* BieuThucTich::daoHam()
{
	// Khai bao uv
	BieuThuc *u = this->m_pBieuThuc;
	BieuThuc *v = this->m_pNext;

	// Tinh dao ham cho u va v
	BieuThuc *daohamu;
	daohamu = this->m_pBieuThuc->daoHam();
	BieuThuc *daohamv = new BieuThuc();
	daohamv = this->m_pNext->daoHam();

	//tao cac bieu thuc tich
	BieuThuc *daohamu_v = new BieuThucTich(daohamu,v);
	BieuThuc *daohamv_u = new BieuThucTich(daohamv,u);

	// Tao bieu thuc tong
	BieuThuc *ketqua = new BieuThucTong(daohamu_v,daohamv_u);

	return ketqua;
}

BieuThucTich::~BieuThucTich(void)
{
	delete [] this->m_pBieuThuc;
	delete [] this->m_pNext;
}
